
<div class="row clearfix">
    
        
                <Legend>Informasi Jaringan</legend>
                <?php //echo $this->today; ?>

<div class="col-md-6 column">
    <form method="post" id="frm" name="frm">

            <?php //echo $this->today;?>


            <br>
            <!-- fromAcc input-->
            <div class="form-group">
                
                 <input id="parent_code" name="parent_code" type="text" placeholder="Level/Parent Code"
                 class="form-control" >

                 <button class="btn btn-default" type="button" id="btnSubmit" name="btnSubmit"
                         onclick="getData()">
                    Tampilkan</button>
            </div>
          
    </form>
    </div>

                <br><br><br><br><br><br><br>
    <div class="col-md-12 column">

    <table id="infonetwork" class="easyui-datagrid" title="Daftar Jaringan" style="height:300px"
                data-options="
                        url: '<?php echo $this->baseUrl() ?>/jsondata/infonetwork',
                        fitColumns: false,
                        singleSelect: true,
                        rownumbers: true,
                        autoRowHeight:true,
                        autoRowWidth:true,
                        pagination:true,
                        pageSize:10
                ">
        <thead>
                <tr>
                    <th data-options="field:'member_id',width:110" align="right">Member ID</th>
                        <th data-options="field:'member_code',width:130">Kode Member</th>
                        <th data-options="field:'matrik_level',width:80" align="right">Level</th>
                        <th data-options="field:'reg_dtm',width:120">Tanggal Daftar</th>

                </tr>
        </thead>
    </table>
    <br>


</div>
</div>

<script>

$('#infonetwork').datagrid({
	onClickRow: function(rowIndex, rowData){
                $('#parent_code').val(rowData['member_code']);
		getData();
	}
});

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

function getData(){

            var val = $('#parent_code').val();
            var parent_code = "";
            var level = "";

            if(isNumber(val)){
                level = val;
            }else{
                parent_code = val;
            }


            $('#infonetwork').datagrid({
                queryParams: {
                page: 1,
                rows: 10,
                parent_code: parent_code,
                level: level
                }
                });

            var pager = $('#infonetwork').datagrid('getPager');	// get the pager of datagrid
            pager.pagination({
                    buttons:[{
                            iconCls:'icon-pdf',
                            handler:function(){
                                    downloadPDF();
                            }
                    }]
            });
    }
</script>





